/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.PitchNotes;
import com.openbrew.openbrewrf.YeastGens;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "Yeast")
@XmlRootElement
public class YeastView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "YID")
    private Integer yid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 80)
    @Column(name = "YeastName")
    private String yeastName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YeastBasePitchRate")
    private float yeastBasePitchRate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YeastAdditionalPitchRate")
    private float yeastAdditionalPitchRate;
    @OneToMany(mappedBy = "yeast")
    private Collection<PitchNotes> pitchNotesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "yGYeastID")
    private Collection<YeastGens> ygCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "yGYeastID")
    private Collection<YeastGensView> ygViewCollection;

    public YeastView() {
    }

    public YeastView(Integer yid) {
        this.yid = yid;
    }

    public YeastView(Integer yid, String yeastName, float yeastBasePitchRate, float yeastAdditionalPitchRate) {
        this.yid = yid;
        this.yeastName = yeastName;
        this.yeastBasePitchRate = yeastBasePitchRate;
        this.yeastAdditionalPitchRate = yeastAdditionalPitchRate;
    }

    public Integer getYid() {
        return yid;
    }

    public void setYid(Integer yid) {
        this.yid = yid;
    }

    public String getYeastName() {
        return yeastName;
    }

    public void setYeastName(String yeastName) {
        this.yeastName = yeastName;
    }

    public float getYeastBasePitchRate() {
        return yeastBasePitchRate;
    }

    public void setYeastBasePitchRate(float yeastBasePitchRate) {
        this.yeastBasePitchRate = yeastBasePitchRate;
    }

    public float getYeastAdditionalPitchRate() {
        return yeastAdditionalPitchRate;
    }

    public void setYeastAdditionalPitchRate(float yeastAdditionalPitchRate) {
        this.yeastAdditionalPitchRate = yeastAdditionalPitchRate;
    }

    @XmlTransient
    public Collection<PitchNotes> getPitchNotesCollection() {
        return pitchNotesCollection;
    }

    public void setPitchNotesCollection(Collection<PitchNotes> pitchNotesCollection) {
        this.pitchNotesCollection = pitchNotesCollection;
    }

    @XmlTransient
    public Collection<YeastGens> getYGCollection() {
        return ygCollection;
    }

    public void setYGCollection(Collection<YeastGens> ygCollection) {
        this.ygCollection = ygCollection;
    }

    @XmlTransient
    public Collection<YeastGensView> getYgViewCollection() {
        return ygViewCollection;
    }

    public void setYgViewCollection(Collection<YeastGensView> ygViewCollection) {
        this.ygViewCollection = ygViewCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (yid != null ? yid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof YeastView)) {
            return false;
        }
        YeastView other = (YeastView) object;
        if ((this.yid == null && other.yid != null) || (this.yid != null && !this.yid.equals(other.yid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.YeastView[ yid=" + yid + " ]";
    }
}
